Add commits order index#64
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds EFCore.ComplexIndexes (managed version 3.1.5 and project PackageReference) and uses it in CommitEntityConfig to create a named composite index IX_Commits_DateTime_Counter_Id over HybridDateTime.DateTime, HybridDateTime.Counter, and Id; verified model output updated. ChangesComplex Composite Index Implementation
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
2e408a0 to
64ea174
Compare
64ea174 to
d1aa44c
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/SIL.Harmony/Db/EntityConfig/CommitEntityConfig.cs`:
- Around line 29-31: The call in CommitEntityConfig currently uses a
non-existent named parameter indexName on HasComplexCompositeIndex; switch to
the overload that accepts an Action<ComplexIndexBuilder> and set the
ComplexIndexAnnotations.IndexName inside that configure callback so the index
name "IX_Commits_DateTime_Counter_Id" is applied (i.e., replace the current
HasComplexCompositeIndex(c => new { c.HybridDateTime.DateTime,
c.HybridDateTime.Counter, c.Id }, indexName: "...") with
HasComplexCompositeIndex(columns => ..., cfg =>
cfg.Annotations[ComplexIndexAnnotations.IndexName] =
"IX_Commits_DateTime_Counter_Id" or equivalent on ComplexIndexBuilder).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: e6ddd030-9a6c-43d1-a603-143b43aa54d8
📒 Files selected for processing (4)
Directory.Packages.propssrc/SIL.Harmony.Tests/DbContextTests.VerifyModel.verified.txtsrc/SIL.Harmony/Db/EntityConfig/CommitEntityConfig.cssrc/SIL.Harmony/SIL.Harmony.csproj
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
@myieye Hey, I am the author of EFCore.ComplexIndexes. I am very happy that my package is actually being considered useful in other projects as well :-) Wanted to inform you: I just released version 3.1.0 that allows specifying specific sort orders in multi-column complex indexes:
builder.HasComplexCompositeIndex(
c => new { c.HybridDateTime.DateTime, Counter = DbOrder.Desc(c.HybridDateTime.Counter), c.Id },
indexName: "IX_Commits_DateTime_Counter_Id");
// CREATE INDEX "IX_Commits_DateTime_Counter_Id" ON ... ("DateTime", "Counter" DESC, "Id"); |
3.1.0 added per-column sort direction support, so update the comment to reflect that we don't need it (both Harmony sorts are uniform-direction) rather than that the package can't express it. Co-authored-by: Claude <noreply@anthropic.com>
Adds a composite index on
Commits (DateTime, Counter, Id)— the columns of Harmony's canonical order (DefaultOrder), which most commit read paths use (sync, snapshot construction, validation). Without it each of those sorts the full commit set; with it they're index scans, and the win grows with commit count. One all-ASC index covers both directions —DefaultOrderDescendingis served by a backward scan.Low maintenance cost here: commits are append-mostly and the leading
(DateTime, Counter)key is ~monotonic, so inserts land at the B-tree tail rather than fragmenting it.Uses
EFCore.ComplexIndexesbecause EF can't natively index a mix of ComplexProperty (HybridDateTime) members and scalars (dotnet/efcore#11336, targeted for EF 11).Summary by CodeRabbit
New Features
Chores